// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement;

public sealed partial class Merge
{
	[JsonInclude, JsonPropertyName("scheduler")]
	public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.MergeScheduler? Scheduler { get; set; }
}

public sealed partial class MergeDescriptor : SerializableDescriptor<MergeDescriptor>
{
	internal MergeDescriptor(Action<MergeDescriptor> configure) => configure.Invoke(this);

	public MergeDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Serverless.IndexManagement.MergeScheduler? SchedulerValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.IndexManagement.MergeSchedulerDescriptor SchedulerDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.MergeSchedulerDescriptor> SchedulerDescriptorAction { get; set; }

	public MergeDescriptor Scheduler(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.MergeScheduler? scheduler)
	{
		SchedulerDescriptor = null;
		SchedulerDescriptorAction = null;
		SchedulerValue = scheduler;
		return Self;
	}

	public MergeDescriptor Scheduler(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.MergeSchedulerDescriptor descriptor)
	{
		SchedulerValue = null;
		SchedulerDescriptorAction = null;
		SchedulerDescriptor = descriptor;
		return Self;
	}

	public MergeDescriptor Scheduler(Action<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.MergeSchedulerDescriptor> configure)
	{
		SchedulerValue = null;
		SchedulerDescriptor = null;
		SchedulerDescriptorAction = configure;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (SchedulerDescriptor is not null)
		{
			writer.WritePropertyName("scheduler");
			JsonSerializer.Serialize(writer, SchedulerDescriptor, options);
		}
		else if (SchedulerDescriptorAction is not null)
		{
			writer.WritePropertyName("scheduler");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.IndexManagement.MergeSchedulerDescriptor(SchedulerDescriptorAction), options);
		}
		else if (SchedulerValue is not null)
		{
			writer.WritePropertyName("scheduler");
			JsonSerializer.Serialize(writer, SchedulerValue, options);
		}

		writer.WriteEndObject();
	}
}